package formbeans;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class FixedChoiceForm extends FormBean {

	private String question;
	private String num;
	
	public String getQuestion() {
		return question;
	}
	public String getNum() {
		return num;
	}

	public void setQuestion(String question) {
		this.question = trimAndConvert(question,"<>\"");
	}
	public void setNum(String num) {
		this.num = trimAndConvert(num,"<>\"");
	}
	
	public List<String> checkFixedChoiceFormErrors(){
		List<String> errors = new ArrayList<String>();
		
		if(question == null || question.length() == 0){
			errors.add("Please enter a question");
		}
		
		if(num == null || num.length() == 0) {
			errors.add("Please enter number of choices");
			return errors;
		}
		
		try {
			int i = new Integer(num);
			if (i < 4 || i > 100)
				errors.add("Please enter number between 4 and 100, inclusive");
		} catch (NumberFormatException e) {
			errors.add("Please enter valid number");
		}
		
		return errors;
	}
}